package com.fan.teamer.service;

import java.util.List;

import javax.inject.Inject;
import javax.inject.Named;

import org.springframework.transaction.annotation.Transactional;

import com.fan.teamer.model.dao.AttendanceDao;
import com.fan.teamer.model.domain.Attendance;
import com.fan.teamer.model.domain.Event;
import com.fan.teamer.model.domain.Member;
import com.fan.teamer.model.domain.Team;

@Named("attendanceService")
@Transactional(readOnly = true)
public class AttendanceServiceImpl implements AttendanceService {

	@Inject
	@Named("attendanceDao")
	private AttendanceDao attendanceDao;

	public AttendanceDao getAttendanceDao() {
		return attendanceDao;
	}

	public void setAttendanceDao(AttendanceDao attendanceDao) {
		this.attendanceDao = attendanceDao;
	}

	@SuppressWarnings("rawtypes")
	@Override
	public List getList() {
		return attendanceDao.getAllAttendances();
	}

	@Override
	public int getColumnsSize() {
		return attendanceDao.getColumnNames().size();
	}

	@Override
	public Object copy(Object obj) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Attendance getAttendance(int id) {
		return attendanceDao.getAttendance(id);
	}

	@Override
	public List<Attendance> getAllAttendances() {
		return attendanceDao.getAllAttendances();
	}

	@Override
	public int getSize() {
		return attendanceDao.getSize();
	}

	@Override
	@Transactional(readOnly = false)
	public void addAttendance(Attendance attendance) {
		attendanceDao.addAttendance(attendance);
	}

	@Override
	@Transactional(readOnly = false)
	public void updateStock(Attendance attendance) {
		attendanceDao.updateStock(attendance);
	}

	@Override
	@Transactional(readOnly = false)
	public void deleteAttendance(Attendance attendance) {
		attendanceDao.deleteAttendance(attendance);
	}

	@Override
	public boolean hasAttendance(int id) {
		return attendanceDao.hasAttendance(id);
	}

	@Override
	public List<String> getColumnNames() {
		return attendanceDao.getColumnNames();
	}

	@Override
	public List<Attendance> getMemberAttendance(Member member) {
		return attendanceDao.getMemberAttendance(member);
	}

	@Override
	public List<Attendance> getAttendancesByTeamEvents(Team team, Event event) {
		return attendanceDao.getAttendancesByEvent(event);
	}

	@Override
	public Attendance getAttendance(Event event, Member member) {
		return attendanceDao.getAttendance(event, member);
	}

}
